<template>
  <div class="main" v-color="'bgkImg'">
    <dz-nav :is-back="true" back-url="/my">
      <template #center>
        <b v-color class="fontSize14"><qq>SettransactionPassword</qq></b>
      </template>
    </dz-nav>
    <div class="box-1">
      <dz-input
          v-model="form.oldPassword"
          :rule="rule.oldPassword"
          :rule-label="$t('PleaseenterOldtransactionpassword')"
          type="password"
          :placeholder="$t('PleaseenterOldtransactionpassword')"
          :label="$t('Oldtransactionpassword')"/>
      <dz-input
          v-model="form.newPassword"
          :rule="rule.newPassword"
          :rule-label="$t('Enteranewtransactionpassword')"
          type="password"
          :placeholder="$t('Enteranewtransactionpassword')"
          :label="$t('Setnewtransactionpassword')"/>
      <dz-input
          v-model="form.confirm"
          :rule="rule.confirm"
          :rule-label="$t('Reentertransactionpassword')"
          type="password"
          :placeholder="$t('Reentertransactionpassword')"
          :label="$t('Confirmthenewtransactionpassword')"/>
      <div class="bottom-btn">
        <dz-button @click="submit"><qq>confirm</qq></dz-button>
      </div>
      <dz-safe></dz-safe>
    </div>
  </div>
</template>

<script>
import {changePassword, changePayPassword} from "@/api/apiFox";
import {Toast} from "vant";

export default {
  data(){
    return{
      input:'',
      form:{newPassword:'',oldPassword:'',confirm:''},
      rule:{newPassword:false,oldPassword:false,confirm:false}
    }
  },
  methods:{
    submit(){
      if (this.form.oldPassword  === ''){
        this.rule.oldPassword=true
      }else if (this.form.newPassword===''){
        this.rule.newPassword=true
      }else if (this.form.confirm !== this.form.newPassword){
        this.rule.confirm = true
      } else{
        console.log(this.input)
        this.rule ={newPassword:false,oldPassword:false,confirm: false}
        changePayPassword(this.form).then(res=>{
          console.log(res)
          Toast.success(this.$t('Success'))
          for (let key in this.form){
            this.form[key] = ''
          }
        }).catch(err=>{})
      }

    },
    phone(item){
      console.log(item)
    }
  },
}
</script>

<style scoped lang="scss">
.main{
  width: 100%;
  min-height: 100vh;
  .box-1{
    width: 375px;
    min-height: calc(100vh - 50px);
    background: linear-gradient( 180deg, #FFF0C9 0%, #D49188 100%);
    border-radius: 30px 30px 0px 0px;
    padding: 35px 16px;
    box-sizing: border-box;
    position: relative;
    .bottom-btn{
      width: 100%;
      padding: 35px 16px;
      box-sizing: border-box;
      position: absolute;
      bottom: 30px;
      left: 0;
      .button{
        width: 100%;
        height: 50px;
        background: linear-gradient( 90deg, #973DF1 0%, #5134C3 100%);
        box-shadow: 0px 4px 4px 0px rgba(92,18,187,0.25), inset 0px 4px 4px 0px rgba(249,249,249,0.25);
        border-radius: 30px 30px 30px 30px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-weight: 800;
        font-size: 16px;

        color: #FFFFFF;
      }
    }

  }
}
</style>